{% extends "_layouts/edit.html" -%}
{% block body %}
<div class="layui-form-item">
    <label for="parent_id" class="layui-form-label"> <span class="x-red">*</span>上级菜单: </label>
    <div class="layui-input-inline">
        <select name="parent_id" lay-verify="required">
            <option value="0">无上级菜单</option>
            {% for key, value in menus -%}
            <option value="{{key}}" {% if row.parent_id == value %}selected="selected"{% endif %}>{{value}}</option>
            {% endfor -%}
        </select>
    </div>
    <div class="layui-form-mid layui-word-aux"> </div>
</div>
{{ form::input(name="name", title="菜单名称", value=row.name) }}
<div class="layui-form-item">
    <label for="level_id" class="layui-form-label"> <span class="x-red">*</span>菜单级别: </label>
    <div class="layui-input-inline">
        <select name="level_id" lay-verify="required">
            <option value="0" {% if row.level_id == 0 %}selected="selected"{% endif %}>一级菜单</option>
            <option value="1" {% if row.level_id == 1 %}selected="selected"{% endif %}>二级菜单</option>
        </select>
    </div>
    <div class="layui-form-mid layui-word-aux"> </div>
</div>
{{ form::input(name="url", title="路由地址", value=row.url, length=380) }}
{{ form::yes_no(name="is_blank", title="是否外链", value=row.is_blank) }}
{{ form::seq(value=row.seq) }}
{{ form::state(name="state", title="状态", value=row.state) }}
{{ form::yes_no(name="is_show", title="是否显示", value=row.is_show) }}
<script>
layui.validators = { 
    name: function(value) { 
        if (value.length < 2 || value.length > 20) { 
            return '必须输入正确的菜单名称';
        }
    },
    url: function(value) { 
        if (value == "") { 
            return '路由地址不能为空';
        }
    },
    seq: function(value) { 
        if (isNaN(value)) { 
            return '排序必须是有效的数字';
        }
    }
};
</script>
{% endblock body -%}
